<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>首页</title>
  <!-- 新 Bootstrap 核心 CSS 文件 -->
  <link rel="stylesheet" href="../../../css/bootstrap.min.css">
  <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  <script src="../../../js/jquery.min.js"></script>
  <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
  <script src="../../../js/bootstrap.min.js"></script>

  <script src="../js/jquery.ajaxupload.js"></script>
</head>
<script>
  window.onload=function(){
    var uid= localStorage.getItem('shop_uid');
    var user=localStorage.getItem('shop_user');
    document.getElementById('uid').value=uid;
    document.getElementById('user').value=user;
    $.ajaxUploadSettings.name='file';
    $('#upload').ajaxUploadPrompt({
      url:'/upload',//上传位置
      success(data){  //回调函数，图片上传成功时会调用该函数。
           console.log(data);
          $('#upload').prev().val(data);
          $('#upload').next().attr('src',data);
      }
    }); //js中{}代表对象
  }
</script>
<body>
<ul class="breadcrumb" style="margin:0;">
  <li><a href="#">商品管理</a></li>
    <#if bean??>
    <li>修改商品</li>
    <#else>
  <li>添加商品</li>
    </#if>

</ul>
<form action="" method="post" class="form-horizontal">
 <input type="hidden" name="id" value="${(bean.id)!}"/>
  <h5 class="page-header alert-info" style="padding:10px;margin:0 0 10px 0;">基本信息</h5>
  <div class="row col-sm-9 form-group">
    <label class="col-sm-3 control-label">商品名称</label>
    <div class="col-sm-6">
      <input type="text" name="product" class="form-control input-sm" value="${(bean.product)!}"/>
    </div>
  </div>
  <div class="row col-sm-9 form-group">
    <label class="col-sm-3 control-label">单价</label>
    <div class="col-sm-6">
      <input type="number" name="price" class="form-control input-sm" value="${((bean.price)?c)!}"/>
    </div>
  </div>
  <div class="row col-sm-9 form-group">
    <label class="col-sm-3 control-label">图片</label>
    <div class="col-sm-6">
      <input type="hidden" name="logo" class="form-control input-sm" value="${(bean.logo)!}"/>
      <input id="upload" type="button" class="btn btn-success " value="上传"/>
      <img src="${(bean.logo)!}" style="display: block; max-width: 500px"/>
    </div>
  </div>
  <div class="row col-sm-9 form-group">
    <label class="col-sm-3 control-label">是否热卖</label>
    <div class="col-sm-6">
      <select name="hot" class="form-control input-sm" >
        <option <#if (bean.hot)??&&(bean.hot=='热卖')>selected </#if> >热卖</option>
        <option <#if (bean.hot)??&&(bean.hot=='非热卖')>selected </#if>>非热卖</option>
      </select>
    </div>
  </div>
  <div class="row col-sm-9 form-group">
    <label class="col-sm-3 control-label">库存</label>
    <div class="col-sm-6">
      <input type="number" name="num" class="form-control input-sm" value="${((bean.num)?c)!}"/>
    </div>
  </div>
  <div class="row col-sm-9 form-group">
    <label class="col-sm-3 control-label">商家</label>
    <div class="col-sm-6">
      <input id="uid" type="hidden" name="uid" class="form-control input-sm" value=""/>
      <input id="user" readonly class="form-control input-sm"/>
    </div>
  </div>
  <div class="row col-sm-9 form-group">
    <label class="col-sm-3 control-label">类别</label>
    <div class="col-sm-6">
      <select  name="cid" class="form-control input-sm">
        <#list cateList as cate>
         <option value="${cate.id}"
         <#if (bean.cid)??&&(bean.cid)==cate.id> selected</#if>
         > ${cate.category}</option>
        </#list>
      </select>
    </div>
  </div>

  <div class="col-sm-3 col-sm-offset-4">
    <input  type="submit" class="btn btn-success" value="保存"/>
    <a class="btn btn-warning" href="javascript:history.back()">返回上一级</a>
  </div>
</form>

</body>
</html>
